import { Code } from '~/components/text/code'

export const meta = {
  editUrl: 'pages/docs/api/v2/api-docs-mdx/errors/domains.mdx',
  lastEdited: '2019-10-22T09:28:13.000Z'
}

## Domain Errors

These error code could happen when using any [domains related endpoints](#endpoints/domains).

### Domain Forbidden

You don't have access to the domain, this usually mean this domains is owned by another account or team.

The domain is specified in the message and the `DOMAIN` key.

<Code lang="json">{`{
  "error": {
    "code": "forbidden",
    "message": "You don't have access to \\"DOMAIN\\"",
    "domain": DOMAIN
  }
}`}</Code>

### Domain Not Found

The domain name could not be found in our system. Try to [add it first](#endpoints/domains/add-a-new-domain).

<Code lang="json">{`{
  "error": {
    "code": "not_found",
    "message": "Domain name not found"
  }
}`}</Code>

### Missing Domain Name

The domain name wasn't specified in the URL. This means you tried to use an endpoint which require you to define the domain name in the URL but didn't defined it.

<Code lang="json">{`{
  "error": {
    "code": "missing_name",
    "message": "The URL was expected to include the domain name. Example: /domains/google.com"
  }
}`}</Code>

### Conflicting Certificates

You must [remove the certificates](#endpoints/certificates/delete-a-certificate) described in the error before removing the domains.

The certificates are specified in the `CERT_CNS` key.

<Code lang="json">{`{
  "error": {
    "code": "conflict_certs",
    "message": "The following certificates must be removed before removing the domain: CERT_CNS",
    "certCNs": CERT_CNS
  }
}`}</Code>

### Conflicting Aliases

You must [remove the aliases](#endpoints/aliases/remove-an-alias) described in the error before removing the domains.

The aliases are specified in the `ALIASES` key.

<Code lang="json">{`{
  "error": {
    "code": "conflict_aliases",
    "message": "The following aliases must be removed before removing the domain: ALIASES",
    "aliases": ALIASES
  }
}`}</Code>

### Not Modified

When trying to modify a domain nothing was required to change.

<Code lang="json">{`{
  "error": {
    "code": "not_modified",
    "message": "Nothing to do"
  }
}`}</Code>

### Missing Name for Domain

When trying to add a domain the name wasn't present in the request body.

<Code lang="json">{`{
  "error": {
    "code": "missing_name",
    "message": "The \`name\` field in the body was expected but is not present in the body payload. Example value: \`zeit.co\`"
  }
}`}</Code>

### Invalid Name for Domain

The domain name defined in the request body is invalid.

The name is specified in the error as the `NAME` key.

<Code lang="json">{`{
  "error": {
    "code": "invalid_name",
    "message": "The \`name\` field contains an invalid domain name ("NAME")",
    "name": NAME
  }
}`}</Code>

### Custom Domain Needs a Plan Upgrade

In order to add a custom domain to your account or team you need to upgrade to a paid plan.

<Code lang="json">{`{
  "error": {
    "code": "custom_domain_needs_upgrade",
    "message": "Domain name creation requires a premium account."
  }
}`}</Code>

### Domain Already Exists

The domain name you're trying to add already exists.

The domain name and its current ID are received in the `NAME` and `DOMAIN_ID` keys.

<Code lang="json">{`{
  "error": {
    "code": "not_modified",
    "message": "The domain "NAME" already exists",
    "name": NAME,
    "uid": DOMAIN_ID
  }
}`}</Code>

### Can't Create the Domain

The domain name can't be created. Most probably it couldn't be verified.

<Code lang="json">{`{
  "error": {
    "code": "forbidden",
    "message": "You don't have permission to create a domain"
  }
}`}</Code>

### Failed to Add Domain after Purchase

We were able to purchase a domain for you but we had an error when trying to add it to your account. Please contact us on [zeit.chat](/chat) or via [support@zeit.com](mailto:support@zeit.co).

<Code lang="json">{`{
  "error": {
    "code": "failed_to_add_domain",
    "message": "The domain was bought but couldn't be added. Please contact us on https://zeit.chat"
  }
}`}</Code>

### Unable to Determine the Domain Price

We're unable to determine the domain price of a domain.

<Code lang="json">{`{
  "error": {
    "code": "service_unavailable",
    "message": "Failed to determine the domain price"
  }
}`}</Code>

### Domain price mismatch

The `expectedPrice` supplied in the request body does not match the actual domain price, which is specified in the `actualPrice` key.

<Code lang="json">{`{
  "error": {
    "code": "price_mismatch",
    "message": "The expected price does not match the actual price",
    "price": ACTUAL_PRICE
  }
}`}</Code>

### Domain Is Not Available

The domain name is not available to be purchased.

<Code lang="json">{`{
  "error": {
    "code": "not_available",
    "message": "Domain is not available"
  }
}`}</Code>

### Invalid Domain Name

The domain name or TLD is invalid or not supported.

<Code lang="json">{`{
  "error": {
    "code": "invalid_domain",
    "message": "Invalid domain or TLD"
  }
}`}</Code>

### Missing DNS Record Name

The DNS record key `name` is required and was not provided. It could be [any valid DNS record](https://en.wikipedia.org/wiki/List_of_DNS_record_types).

<Code lang="json">{`{
  "error": {
    "code": "missing_type",
    "message": "Missing \`type\` parameter"
  }
}`}</Code>
